package robot

import (
	"github.com/sssxyd/rpa-execution-protocol/basic"
	"github.com/sssxyd/rpa-execution-protocol/browser"
	"github.com/sssxyd/rpa-execution-protocol/osgui"
	"github.com/sssxyd/rpa-execution-protocol/wxapp"
)

type ScriptType string

const (
	GuiOperator     ScriptType = "gui"
	BrowserOperator ScriptType = "browser"
	WxAppOperator   ScriptType = "wxapp"
)

type GoScript interface {
	GetID() string                        // 唯一标识符
	GetType() ScriptType                  // 脚本类型
	Prepare() (bool, error)               // 检查脚本对应的资源是否准备就绪
	Keepalive() error                     // 长时间无任务时，调用以保持脚本对应的资源活跃
	Execute(task basic.Task) (any, error) // 执行脚本任务
	BindProject(project ProjectExecutor)  // 绑定项目执行器
	BindWasm(wasm WasmWrapper)            // 绑定WASM执行器
}

// 操作GUI窗口的脚本接口
type GuiScript interface {
	GoScript
	BindWindow(window osgui.GuiWindow) // 绑定GUI窗口
}

// 操作浏览器窗口的脚本接口
type BrowserScript interface {
	GoScript
	BindWindow(window browser.BrowserWindow) // 绑定浏览器窗口
}

// 操作微信小程序窗口的脚本接口
type WxAppScript interface {
	GoScript
	BindWindow(window wxapp.WxAppWindow) // 绑定微信小程序窗口
}
